package updown.config;


import com.netflix.eureka.DefaultEurekaServerConfig;
import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.resources.DefaultServerCodecs;
import com.netflix.eureka.resources.ServerCodecs;
import com.netflix.eureka.transport.JerseyReplicationClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>Title: ww.kaixin.downupservice.config </p>
 * <p>Description:to-22-6-1: -  </p>
 *
 * @Author:jiangkaixin
 * @Date:12/19/2021
 * @Version: 1.0
 */
@Configuration
@Data
public class MyEurekaServerConfig {

    @Value("${eureka.client.serviceUrl.defaultZone}")
    public String serviceUrl;


    @Bean
    public EurekaServerConfig serverConfig(){
        return new DefaultEurekaServerConfig();
    }

    @Bean
    public ServerCodecs serverCodecs(EurekaServerConfig serverConfig){
        return new DefaultServerCodecs(serverConfig);
    }

    @Bean
    public JerseyReplicationClient client(EurekaServerConfig serverConfig, ServerCodecs serverCodecs, MyEurekaServerConfig myEurekaServerConfig){
        return JerseyReplicationClient.createReplicationClient(serverConfig, serverCodecs, myEurekaServerConfig.getServiceUrl());
    }
}
